#pragma once

// ---- include bsp.h for hardware supports
#include <bsp.h>
// ---- else
#include <memory>
#include <vector>
#include <signal_os.h>

#define DMA_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNDTR = (uint16_t)(__COUNTER__))

namespace os {
class Uart final {
private:
    UART_HandleTypeDef* handle_{};

    explicit Uart(UART_HandleTypeDef* uart_handle) : handle_(uart_handle) {
    }

public:
    Uart(Uart const&) = delete;
    Uart& operator=(Uart const&) = delete;

    static Uart& Instance(USART_TypeDef* uart);
    UART_HandleTypeDef* GetHandlePtr();

    Signal<uint8_t*, uint16_t> on_receive{};

    HAL_StatusTypeDef Transmit(uint8_t const* tx_buffer, uint16_t len);
};
} // namespace os